// 定义默认状态
const defaultState = {
    showLoading: false,     // Loading组件的显示隐藏
    showAlert: false,        // Alert的显示隐藏
    alertContent: "暂未开放", // Alert的内容
    alertColor: "warning"     //error,warning,info,success

}

// 返回一个函数
// eslint-disable-next-line
export default (state=defaultState, action) => {
    let newState = JSON.parse(JSON.stringify(state));
    switch(action.type){
        case "closeLoading":    // 关闭loading
            newState.showLoading = false;
            break;
        case "openLoading":    // 打开loading
            newState.showLoading = true;
            break;
        case "showalert":    // 打开警告框
            newState.showAlert = true;
            newState.alertColor = action.value.color
            newState.alertContent = action.value.textvalue;
            break;
        case "hidealert":    // 关闭警告框
            newState.showAlert = false;
            break;
        default:
            break;
    }
    return newState;
}